﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace 影片售票系统.Yly
{
    public partial class Movie : Form
    {
        //int id;
        string name;
        public Movie()
        {
            InitializeComponent();           
        }
        //public Movie(int idd)
        //{
        //    InitializeComponent();
        //    id = idd;
        //}
        public Movie(string names)
        {
            InitializeComponent();
             name = names;
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void Movie_Load(object sender, EventArgs e)
        {
            link_buy.BackColor = Color.Transparent;
            //获取影片信息
            #region
            //if (id != 0)
            //{
               
            //    string sql = string.Format("select * from T_movie where id={0}", id);
            //    DataTable table = common.DBHelper.read(sql);
            //    this.lik_name.Text = table.Rows[0]["name"].ToString();
            //    this.lab_jieshao.Text = table.Rows[0]["jianjie"].ToString();
            //}
            //else
            //{
            //    string sql = string.Format("select * from T_movie where name='{0}'", name);
            //    DataTable table = common.DBHelper.read(sql);
            //    this.lik_name.Text = table.Rows[0]["name"].ToString();
            //    this.lab_jieshao.Text = table.Rows[0]["jianjie"].ToString();
            //}
             
             string sql1 = string.Format("select * from T_movie where name='{0}'", name);
             DataTable table1 = common.DBHelper.read(sql1);
             string nm = table1.Rows[0]["lujin"].ToString();
             this.lik_name.Text = table1.Rows[0]["name"].ToString();
             this.pictureBox1.Image = Image.FromFile(nm);
             this.lab_date.Text = table1.Rows[0]["shichang"].ToString();
             this.lab_type.Text = table1.Rows[0]["Type"].ToString();
             this.lab_jieshao.Text = table1.Rows[0]["jianjie"].ToString();
             this.lab_guojia.Text = table1.Rows[0]["guojia"].ToString();
             this.lab_date.Text = table1.Rows[0]["date"].ToString();
            #endregion


        }

        private void bangdan_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Top top = new Top();
            top.Show();
        }

        private void link_buy_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        { 
            //判断用户是否已经登录
            string sql="select * from T_zt";
            DataTable table = common.DBHelper.read(sql);
            int zt =Convert.ToInt16(table.Rows[0]["zhuangtai"]);
            if (zt == 0)
            {
                Zq.Denglu denglu = new Zq.Denglu();
                denglu.Show();
            }
            else
            {
                Buy buy = new Buy();
                buy.Show();
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void shouye_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            MainForm mainform = new MainForm();
            mainform.Show();
            this.Close();
        }

        private void lab_Top1_Click(object sender, EventArgs e)
        {
            string name = this.lab_Top1.Text.Trim();
            Yly.Movie movie = new Yly.Movie(name);
            this.Close();
            movie.Show();
        }

        private void bangdan_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Top top = new Top();
            this.Close();
            top.Show();
        }

        private void lab_Top2_Click(object sender, EventArgs e)
        {
          
      
        }

        private void lab_Top1_Click_1(object sender, EventArgs e)
        {
            string qw = this.lab_Top1.Text.Trim();
            string sql1 = string.Format("select * from T_movie where name='{0}'", qw);
            DataTable table1 = common.DBHelper.read(sql1);
            string nm = table1.Rows[0]["lujin"].ToString();
            this.lik_name.Text = table1.Rows[0]["name"].ToString();
            this.pictureBox1.Image = Image.FromFile(nm);
            this.lab_date.Text = table1.Rows[0]["shichang"].ToString();
            this.lab_type.Text = table1.Rows[0]["Type"].ToString();
            this.lab_jieshao.Text = table1.Rows[0]["jianjie"].ToString();
            this.lab_guojia.Text = table1.Rows[0]["guojia"].ToString();
            this.lab_date.Text = table1.Rows[0]["date"].ToString();
        }

        private void lab_Top3_Click(object sender, EventArgs e)
        {
            string qw = this.lab_Top3.Text.Trim();
            string sql1 = string.Format("select * from T_movie where name='{0}'", qw);
            DataTable table1 = common.DBHelper.read(sql1);
            string nm = table1.Rows[0]["lujin"].ToString();
            this.lik_name.Text = table1.Rows[0]["name"].ToString();
            this.pictureBox1.Image = Image.FromFile(nm);
            this.lab_date.Text = table1.Rows[0]["shichang"].ToString();
            this.lab_type.Text = table1.Rows[0]["Type"].ToString();
            this.lab_jieshao.Text = table1.Rows[0]["jianjie"].ToString();
            this.lab_guojia.Text = table1.Rows[0]["guojia"].ToString();
            this.lab_date.Text = table1.Rows[0]["date"].ToString();
        }

        private void lab_Top4_Click(object sender, EventArgs e)
        {
            string qw = this.lab_Top4.Text.Trim();
            string sql1 = string.Format("select * from T_movie where name='{0}'", qw);
            DataTable table1 = common.DBHelper.read(sql1);
            string nm = table1.Rows[0]["lujin"].ToString();
            this.lik_name.Text = table1.Rows[0]["name"].ToString();
            this.pictureBox1.Image = Image.FromFile(nm);
            this.lab_date.Text = table1.Rows[0]["shichang"].ToString();
            this.lab_type.Text = table1.Rows[0]["Type"].ToString();
            this.lab_jieshao.Text = table1.Rows[0]["jianjie"].ToString();
            this.lab_guojia.Text = table1.Rows[0]["guojia"].ToString();
            this.lab_date.Text = table1.Rows[0]["date"].ToString();
        }

        private void lab_Top5_Click(object sender, EventArgs e)
        {
            string qw = this.lab_Top5.Text.Trim();
            string sql1 = string.Format("select * from T_movie where name='{0}'", qw);
            DataTable table1 = common.DBHelper.read(sql1);
            string nm = table1.Rows[0]["lujin"].ToString();
            this.lik_name.Text = table1.Rows[0]["name"].ToString();
            this.pictureBox1.Image = Image.FromFile(nm);
            this.lab_date.Text = table1.Rows[0]["shichang"].ToString();
            this.lab_type.Text = table1.Rows[0]["Type"].ToString();
            this.lab_jieshao.Text = table1.Rows[0]["jianjie"].ToString();
            this.lab_guojia.Text = table1.Rows[0]["guojia"].ToString();
            this.lab_date.Text = table1.Rows[0]["date"].ToString();
        }

        private void lab_Top2_Click_1(object sender, EventArgs e)
        {
            string qw = this.lab_Top2.Text.Trim();
            string sql1 = string.Format("select * from T_movie where name='{0}'", qw);
            DataTable table1 = common.DBHelper.read(sql1);
            string nm = table1.Rows[0]["lujin"].ToString();
            this.lik_name.Text = table1.Rows[0]["name"].ToString();
            this.pictureBox1.Image = Image.FromFile(nm);
            this.lab_date.Text = table1.Rows[0]["shichang"].ToString();
            this.lab_type.Text = table1.Rows[0]["Type"].ToString();
            this.lab_jieshao.Text = table1.Rows[0]["jianjie"].ToString();
            this.lab_guojia.Text = table1.Rows[0]["guojia"].ToString();
            this.lab_date.Text = table1.Rows[0]["date"].ToString();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Length < 1)
            {
                MessageBox.Show("请输入影片名");
                return;
            }
            string name = this.textBox1.Text.Trim();
            Yly.MovieSelect select = new Yly.MovieSelect(name);
            select.Show();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Top top = new Top();
            this.Close();
            top.Show();
        }
    }
}
